# frozen_string_literal: true
module CommonError
  class LoginError < StandardError
    def message
      '账号或密码错误'
    end
  end

  class AuthTokenError < StandardError
    def message
      'Token 错误'
    end
  end

  class CustomMessageError < StandardError
    attr_reader :message

    def initialize(message)
      @message = message
    end
  end

  class ModelValidationError < StandardError
    attr_reader :message

    def initialize(message)
      @message = message.full_messages.join(', ')
    end
  end

  class ParameterValueNotAllowed < ActionController::ParameterMissing
    attr_reader :values

    def initialize(param, values) # :nodoc:
      @param = param
      @values = values
      super("param: #{param} value only allowed in: #{values}")
    end
  end
end
